﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace VolunteerManager
{
    /// <summary>
    /// WinChangePassword.xaml 的交互逻辑
    /// </summary>
    public partial class WinChangePassword : Window
    {
        public WinChangePassword()
        {
            InitializeComponent();
        }

        private void ChangePass(object sender, RoutedEventArgs e)
        {

            if (Model.Config.CheckPass(this.oldpass.Password))
            {
                if (this.pass1.Password == this.pass2.Password)
                {
                    if (Model.Config.ChnagePass(pass1.Password))
                    {
                        MessageBox.Show("操作已成功", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information);
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("操作失败，请重试", "系统提示", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
                else
                {
                    MessageBox.Show("两次密码输入不相同，请重新输入", "系统提示", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            else
            {
                MessageBox.Show("密码输入错误，请重试", "系统提示", MessageBoxButton.OK, MessageBoxImage.Error);
                this.oldpass.SelectAll();
            }
            
        }

        private void radButton1_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }
    }
}
